package com.yanqu.road.server.cmd.disperseGold;

import com.yanqu.road.entity.log.LogDisperseClientAction;
import com.yanqu.road.pb.disperseGold.DisperseGoldProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.log.AutoLogMgr;
import com.yanqu.road.server.manger.log.LogMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_DISPERSEGOLD_ACTION_UPLOAD, desc = "客户端送财行为上传")
public class DisperseActionUploadCmd extends AbstractCommand {

    private DisperseGoldProto.DisperseActionUpLoadMsg reqMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = DisperseGoldProto.DisperseActionUpLoadMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if(null != reqMsg){
            for(DisperseGoldProto.DisperseActionTempMsg msg: reqMsg.getDataListList()){
                AutoLogMgr.add(new LogDisperseClientAction(player.getUserId(), msg.getDisperseId(), msg.getActionType(), msg.getActionTime(), msg.getReward()));
            }
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
